home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CompInfo( 23946822001.psc / DirsInfo.bas < prev    next >
Encoding:
BASIC Source File  |  2001-07-23  |  15.9 KB  |  506 lines

  1. Attribute VB_Name = "DirsInfo"
  2. Public Enum SHFolders
  3.     CSIDL_DESKTOP = &H0
  4.     CSIDL_INTERNET = &H1
  5.     CSIDL_PROGRAMS = &H2
  6.     CSIDL_CONTROLS = &H3
  7.     CSIDL_PRINTERS = &H4
  8.     CSIDL_PERSONAL = &H5
  9.     CSIDL_FAVORITES = &H6
  10.     CSIDL_STARTUP = &H7
  11.     CSIDL_RECENT = &H8
  12.     CSIDL_SENDTO = &H9
  13.     CSIDL_BITBUCKET = &HA
  14.     CSIDL_STARTMENU = &HB
  15.     CSIDL_DESKTOPDIRECTORY = &H10
  16.     CSIDL_DRIVES = &H11
  17.     CSIDL_NETWORK = &H12
  18.     CSIDL_NETHOOD = &H13
  19.     CSIDL_FONTS = &H14
  20.     CSIDL_TEMPLATES = &H15
  21.     CSIDL_COMMON_STARTMENU = &H16
  22.     CSIDL_COMMON_PROGRAMS = &H17
  23.     CSIDL_COMMON_STARTUP = &H18
  24.     CSIDL_COMMON_DESKTOPDIRECTORY = &H19
  25.     CSIDL_APPDATA = &H1A
  26.     CSIDL_PRINTHOOD = &H1B
  27.     CSIDL_ALTSTARTUP = &H1D '// DBCS
  28.     CSIDL_COMMON_ALTSTARTUP = &H1E '// DBCS
  29.     CSIDL_COMMON_FAVORITES = &H1F
  30.     CSIDL_INTERNET_CACHE = &H20
  31.     CSIDL_COOKIES = &H21
  32.     CSIDL_HISTORY = &H22
  33. End Enum
  34. Private Type ITEMIDLIST
  35.     mkid As Long
  36. End Type
  37.  
  38. Private Declare Function SHGetSpecialFolderLocation _
  39.         Lib "shell32.dll" _
  40.         (ByVal hwndOwner As Long, ByVal nFolder As SHFolders, _
  41.         ppidl As ITEMIDLIST) As Long
  42. Private Declare Sub CoTaskMemFree Lib "ole32.dll" _
  43.         (ByVal pv As Long)
  44. Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
  45.         Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
  46.         ByVal pszPath As String) As Long
  47. 'Windows direktorijum
  48. Public Sub WinDir()
  49. WinPath = String(145, Chr(0))
  50. WinPath = Left(WinPath, GetWindowsDirectory(WinPath, 145))
  51. FrmMain.lbl110.Caption = "Windows folder:  " + WinPath
  52. End Sub
  53. 'Windows\system direktorijum
  54. Public Sub SysDir()
  55. SysPath = String(145, Chr(0))
  56. SysPath = Left(SysPath, GetSystemDirectory(SysPath, 145))
  57. FrmMain.lbl111.Caption = "System folder:  " + SysPath
  58. End Sub
  59. Public Sub TempDir()
  60. Mod2.WinEnv = String(145, Chr(0))
  61. Mod2.WinEnv = Left$(WinEnv, GetEnvironmentVariable("temp", Mod2.WinEnv, 145))
  62. FrmMain.lbl112.Caption = "Temporary folder:  " & Mod2.WinEnv
  63. End Sub
  64. Public Function GetBootDir() As String
  65. Dim oReg As New cRegistry
  66. Dim sys As Object
  67. Set sys = New OS
  68. If sys.IsWinNT Then
  69.     With oReg
  70.         .ClassKey = HKEY_LOCAL_MACHINE
  71.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion\Setup"
  72.         .ValueKey = "BootDir"
  73.         .ValueType = REG_SZ
  74.         GetBootDir = Trim(.Value)
  75.     End With
  76. Else
  77.     With oReg
  78.         .ClassKey = HKEY_LOCAL_MACHINE
  79.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion\Setup"
  80.         .ValueKey = "BootDir"
  81.         .ValueType = REG_SZ
  82.         GetBootDir = Trim(.Value)
  83.     End With
  84. End If
  85. Set sys = Nothing
  86. Set oReg = Nothing
  87. End Function
  88. Public Sub WinBootDir()
  89. WinEnv = String(145, Chr(0))
  90. WinEnv = Left$(WinEnv, GetEnvironmentVariable("WINBOOTDIR", WinEnv, 145))
  91. FrmMain.lbl113.Caption = "Windows Boot folder:  " + WinEnv
  92. End Sub
  93. Public Sub GetConfigPath()
  94. Dim oReg As New cRegistry
  95. Dim sys As Object
  96. Set sys = New OS
  97. If sys.IsWinNT Then
  98.     With oReg
  99.         .ClassKey = HKEY_LOCAL_MACHINE
  100.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion\Setup"
  101.         .ValueKey = "ConfigPath"
  102.         .ValueType = REG_SZ
  103.         If .Value = "" Then
  104.             .Value = "Unknown or None"
  105.         End If
  106.         FrmMain.lbl115.Caption = "Config path:  " + Trim(.Value)
  107.     End With
  108. Else
  109.     With oReg
  110.         .ClassKey = HKEY_LOCAL_MACHINE
  111.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion\Setup"
  112.         .ValueKey = "ConfigPath"
  113.         .ValueType = REG_SZ
  114.         If .Value = "" Then
  115.             .Value = "Unknown or None"
  116.         End If
  117.         FrmMain.lbl115.Caption = "Config path:  " + Trim(.Value)
  118.     End With
  119. End If
  120. Set sys = Nothing
  121. Set oReg = Nothing
  122. End Sub
  123. Public Sub GetICMPath()
  124. Dim oReg As New cRegistry
  125. Dim sys As Object
  126. Set sys = New OS
  127. If sys.IsWinNT Then
  128.     With oReg
  129.         .ClassKey = HKEY_LOCAL_MACHINE
  130.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion\Setup"
  131.         .ValueKey = "ICMPath"
  132.         .ValueType = REG_SZ
  133.         If .Value = "" Then
  134.             .Value = "Unknown or None"
  135.         End If
  136.         FrmMain.lbl116.Caption = "ICM path:  " + Trim(.Value)
  137.     End With
  138. Else
  139.     With oReg
  140.         .ClassKey = HKEY_LOCAL_MACHINE
  141.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion\Setup"
  142.         .ValueKey = "ICMPath"
  143.         .ValueType = REG_SZ
  144.         If .Value = "" Then
  145.             .Value = "Unknown or None"
  146.         End If
  147.         FrmMain.lbl116.Caption = "ICM path:  " + Trim(.Value)
  148.     End With
  149. End If
  150. Set sys = Nothing
  151. Set oReg = Nothing
  152. End Sub
  153. Public Sub GetMediaPath()
  154. Dim oReg As New cRegistry
  155. Dim sys As Object
  156. Set sys = New OS
  157. If sys.IsWinNT Then
  158.     With oReg
  159.         .ClassKey = HKEY_LOCAL_MACHINE
  160.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion\Setup"
  161.         .ValueKey = "MediaPath"
  162.         .ValueType = REG_SZ
  163.         If .Value = "" Then
  164.             .Value = "Unknown or None"
  165.         End If
  166.         FrmMain.lbl117.Caption = "Media path:  " + Trim(.Value)
  167.     End With
  168. Else
  169.     With oReg
  170.         .ClassKey = HKEY_LOCAL_MACHINE
  171.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion\Setup"
  172.         .ValueKey = "MediaPath"
  173.         .ValueType = REG_SZ
  174.         If .Value = "" Then
  175.             .Value = "Unknown or None"
  176.         End If
  177.         FrmMain.lbl117.Caption = "Media path:  " + Trim(.Value)
  178.     End With
  179. End If
  180. Set sys = Nothing
  181. Set oReg = Nothing
  182. End Sub
  183.  
  184. Public Sub GetDevicePath()
  185. Dim oReg As New cRegistry
  186. Dim sys As Object
  187. Set sys = New OS
  188. If sys.IsWinNT Then
  189.     With oReg
  190.         .ClassKey = HKEY_LOCAL_MACHINE
  191.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion"
  192.         .ValueKey = "DevicePath"
  193.         .ValueType = REG_SZ
  194.         If .Value = "" Then
  195.             .Value = "Unknown or None"
  196.         End If
  197.         FrmMain.lbl118.Caption = "Device path:  " + Trim(.Value)
  198.     End With
  199. Else
  200.     With oReg
  201.         .ClassKey = HKEY_LOCAL_MACHINE
  202.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion"
  203.         .ValueKey = "DevicePath"
  204.         .ValueType = REG_SZ
  205.         If .Value = "" Then
  206.             .Value = "Unknown or None"
  207.         End If
  208.         FrmMain.lbl118.Caption = "Device path:  " + Trim(.Value)
  209.     End With
  210. End If
  211. Set sys = Nothing
  212. Set oReg = Nothing
  213. End Sub
  214. Public Sub GetOtherDevicePath()
  215. Dim oReg As New cRegistry
  216. Dim sys As Object
  217. Set sys = New OS
  218. If sys.IsWinNT Then
  219.     With oReg
  220.         .ClassKey = HKEY_LOCAL_MACHINE
  221.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion"
  222.         .ValueKey = "OtherDevicePath"
  223.         .ValueType = REG_SZ
  224.         If .Value = "" Then
  225.            .Value = "Unknown or None"
  226.         End If
  227.         FrmMain.lbl119.Caption = "Other device path:  " + Trim(.Value)
  228.     End With
  229. Else
  230.     With oReg
  231.         .ClassKey = HKEY_LOCAL_MACHINE
  232.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion"
  233.         .ValueKey = "OtherDevicePath"
  234.         .ValueType = REG_SZ
  235.         If .Value = "" Then
  236.            .Value = "Unknown or None"
  237.         End If
  238.         FrmMain.lbl119.Caption = "Other device path:  " + Trim(.Value)
  239.     End With
  240. End If
  241. Set sys = Nothing
  242. Set oReg = Nothing
  243. End Sub
  244. Public Sub GetCommonFilesPath()
  245. Dim oReg As New cRegistry
  246. Dim sys As Object
  247. Set sys = New OS
  248. If sys.IsWinNT Then
  249.     With oReg
  250.         .ClassKey = HKEY_LOCAL_MACHINE
  251.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion"
  252.         .ValueKey = "CommonFilesDir"
  253.         .ValueType = REG_SZ
  254.         If .Value = "" Then
  255.             .Value = "Unknown or None"
  256.         End If
  257.         FrmMain.lbl11B.Caption = "Common files path:  " + Trim(.Value)
  258.     End With
  259. Else
  260.     With oReg
  261.         .ClassKey = HKEY_LOCAL_MACHINE
  262.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion"
  263.         .ValueKey = "CommonFilesDir"
  264.         .ValueType = REG_SZ
  265.         If .Value = "" Then
  266.             .Value = "Unknown or None"
  267.         End If
  268.         FrmMain.lbl11B.Caption = "Common files path:  " + Trim(.Value)
  269.     End With
  270. End If
  271. Set sys = Nothing
  272. Set oReg = Nothing
  273. End Sub
  274. Public Sub GetProgramFilesPath()
  275. Dim oReg As New cRegistry
  276. Dim sys As Object
  277. Set sys = New OS
  278. If sys.IsWinNT Then
  279.     With oReg
  280.         .ClassKey = HKEY_LOCAL_MACHINE
  281.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion"
  282.         .ValueKey = "ProgramFilesDir"
  283.         .ValueType = REG_SZ
  284.         If .Value = "" Then
  285.             .Value = "Unknown or None"
  286.         End If
  287.         FrmMain.lbl11A.Caption = "Program files path:  " + Trim(.Value)
  288.     End With
  289. Else
  290.     With oReg
  291.         .ClassKey = HKEY_LOCAL_MACHINE
  292.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion"
  293.         .ValueKey = "ProgramFilesDir"
  294.         .ValueType = REG_SZ
  295.         If .Value = "" Then
  296.             .Value = "Unknown or None"
  297.         End If
  298.         FrmMain.lbl11A.Caption = "Program files path:  " + Trim(.Value)
  299.     End With
  300. End If
  301. Set sys = Nothing
  302. Set oReg = Nothing
  303. End Sub
  304. Public Sub GetWallPaperPath()
  305. Dim oReg As New cRegistry
  306. Dim sys As Object
  307. Set sys = New OS
  308. If sys.IsWinNT Then
  309.     With oReg
  310.         .ClassKey = HKEY_LOCAL_MACHINE
  311.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion"
  312.         .ValueKey = "WallPaperDir"
  313.         .ValueType = REG_SZ
  314.         If .Value = "" Then
  315.             .Value = "Unknown or None"
  316.         End If
  317.         FrmMain.lbl11C.Caption = "WallPaper path:  " + Trim(.Value)
  318.     End With
  319. Else
  320.     With oReg
  321.         .ClassKey = HKEY_LOCAL_MACHINE
  322.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion"
  323.         .ValueKey = "WallPaperDir"
  324.         .ValueType = REG_SZ
  325.         If .Value = "" Then
  326.             .Value = "Unknown or None"
  327.         End If
  328.         FrmMain.lbl11C.Caption = "WallPaper path:  " + Trim(.Value)
  329.     End With
  330. End If
  331. Set sys = Nothing
  332. Set oReg = Nothing
  333. End Sub
  334. Public Sub GetPersonalPath()
  335. Dim oReg As New cRegistry
  336. Dim sys As Object
  337. Set sys = New OS
  338. If sys.IsWinNT Then
  339.     With oReg
  340.         .ClassKey = HKEY_LOCAL_MACHINE
  341.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion\explorer\Shell Folders"
  342.         .ValueKey = "Personal"
  343.         .ValueType = REG_SZ
  344.         If .Value = "" Then
  345.             .Value = "Unknown or None"
  346.         End If
  347.         FrmMain.lbl11D.Caption = "Personal folder:  " + Trim(.Value)
  348.     End With
  349. Else
  350.     With oReg
  351.         .ClassKey = HKEY_LOCAL_MACHINE
  352.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion\explorer\Shell Folders"
  353.         .ValueKey = "Personal"
  354.         .ValueType = REG_SZ
  355.         If .Value = "" Then
  356.             .Value = "Unknown or None"
  357.         End If
  358.         FrmMain.lbl11D.Caption = "Personal folder:  " + Trim(.Value)
  359.     End With
  360. End If
  361. Set sys = Nothing
  362. Set oReg = Nothing
  363. End Sub
  364. Public Sub GetCommonAppDataPath()
  365. Dim oReg As New cRegistry
  366. Dim sys As Object
  367. Set sys = New OS
  368. If sys.IsWinNT Then
  369.     With oReg
  370.         .ClassKey = HKEY_LOCAL_MACHINE
  371.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion\explorer\Shell Folders"
  372.         .ValueKey = "Common AppData"
  373.         .ValueType = REG_SZ
  374.         If .Value = "" Then
  375.             .Value = "Unknown or None"
  376.         End If
  377.         FrmMain.lbl11E.Caption = "Common App Data folder:  " + Trim(.Value)
  378.     End With
  379. Else
  380.     With oReg
  381.         .ClassKey = HKEY_LOCAL_MACHINE
  382.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion\explorer\Shell Folders"
  383.         .ValueKey = "Common AppData"
  384.         .ValueType = REG_SZ
  385.         If .Value = "" Then
  386.             .Value = "Unknown or None"
  387.         End If
  388.         FrmMain.lbl11E.Caption = "Common App Data folder:  " + Trim(.Value)
  389.     End With
  390. End If
  391. Set sys = Nothing
  392. Set oReg = Nothing
  393. End Sub
  394. Public Sub GetCommonDesktopPath()
  395. Dim oReg As New cRegistry
  396. Dim sys As Object
  397. Set sys = New OS
  398. If sys.IsWinNT Then
  399.     With oReg
  400.         .ClassKey = HKEY_LOCAL_MACHINE
  401.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion\explorer\Shell Folders"
  402.         .ValueKey = "Common Desktop"
  403.         .ValueType = REG_SZ
  404.         If .Value = "" Then
  405.             .Value = "Unknown or None"
  406.         End If
  407.         FrmMain.lbl11F.Caption = "Common Desktop folder:  " + Trim(.Value)
  408.     End With
  409. Else
  410.     With oReg
  411.         .ClassKey = HKEY_LOCAL_MACHINE
  412.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion\explorer\Shell Folders"
  413.         .ValueKey = "Common Desktop"
  414.         .ValueType = REG_SZ
  415.         If .Value = "" Then
  416.             .Value = "Unknown or None"
  417.         End If
  418.         FrmMain.lbl11F.Caption = "Common Desktop folder:  " + Trim(.Value)
  419.     End With
  420. End If
  421. Set sys = Nothing
  422. Set oReg = Nothing
  423. End Sub
  424.  
  425. Public Sub GetCommonStartupPath()
  426. Dim oReg As New cRegistry
  427. Dim sys As Object
  428. Set sys = New OS
  429. If sys.IsWinNT Then
  430.     With oReg
  431.         .ClassKey = HKEY_LOCAL_MACHINE
  432.         .SectionKey = "Software\Microsoft\Windows NT\CurrentVersion\explorer\Shell Folders"
  433.         .ValueKey = "Common Startup"
  434.         .ValueType = REG_SZ
  435.         If .Value = "" Then
  436.             .Value = "Unknown or None"
  437.         End If
  438.         FrmMain.lbl120.Caption = "Common Startup folder:  " + Trim(.Value)
  439.     End With
  440. Else
  441.     With oReg
  442.         .ClassKey = HKEY_LOCAL_MACHINE
  443.         .SectionKey = "Software\Microsoft\Windows\CurrentVersion\explorer\Shell Folders"
  444.         .ValueKey = "Common Startup"
  445.         .ValueType = REG_SZ
  446.         If .Value = "" Then
  447.             .Value = "Unknown or None"
  448.         End If
  449.         FrmMain.lbl120.Caption = "Common Startup folder:  " + Trim(.Value)
  450.     End With
  451. End If
  452. Set sys = Nothing
  453. Set oReg = Nothing
  454. End Sub
  455. Public Function FolderLocation(lFolder As SHFolders, hwnd As Long) As String
  456.  
  457.     Dim lp As ITEMIDLIST
  458.     Dim tmpStr As String
  459.     SHGetSpecialFolderLocation hwnd, lFolder, lp
  460.     tmpStr = Space$(255)
  461.     SHGetPathFromIDList lp.mkid, tmpStr
  462.     If InStr(tmpStr, Chr$(0)) > 0 Then
  463.         tmpStr = Left$(tmpStr, InStr(tmpStr, Chr$(0)) - 1)
  464.     End If
  465.     CoTaskMemFree lp.mkid
  466.     If tmpStr = "" Then tmpStr = "None Or Unknown"
  467.     FolderLocation = tmpStr
  468.  
  469. End Function
  470. Public Sub AddFolders()
  471. tmpStr = FolderLocation(CSIDL_TEMPLATES, FrmMain.hwnd)
  472. FrmMain.lbl121.Caption = "Shell New folder:  " + tmpStr
  473. tmpStr = FolderLocation(CSIDL_STARTUP, FrmMain.hwnd)
  474. FrmMain.lbl122.Caption = "StartUp folder:  " + tmpStr
  475. tmpStr = FolderLocation(CSIDL_STARTMENU, FrmMain.hwnd)
  476. FrmMain.lbl123.Caption = "Start menu folder:  " + tmpStr
  477. tmpStr = FolderLocation(CSIDL_SENDTO, FrmMain.hwnd)
  478. FrmMain.lbl123.Caption = "SendTo folder:  " + tmpStr
  479. tmpStr = FolderLocation(CSIDL_RECENT, FrmMain.hwnd)
  480. FrmMain.lbl124.Caption = "Recent folder:  " + tmpStr
  481. tmpStr = FolderLocation(CSIDL_PRINTHOOD, FrmMain.hwnd)
  482. FrmMain.lbl125.Caption = "PrinterHood folder:  " + tmpStr
  483. tmpStr = FolderLocation(CSIDL_PRINTERS, FrmMain.hwnd)
  484. FrmMain.lbl126.Caption = "Printers folder:  " + tmpStr
  485. tmpStr = FolderLocation(CSIDL_NETWORK, FrmMain.hwnd)
  486. FrmMain.lbl127.Caption = "Network folder:  " + tmpStr
  487. tmpStr = FolderLocation(CSIDL_NETHOOD, FrmMain.hwnd)
  488. FrmMain.lbl128.Caption = "NetworkHood folder:  " + tmpStr
  489. tmpStr = FolderLocation(CSIDL_INTERNET_CACHE, FrmMain.hwnd)
  490. FrmMain.lbl129.Caption = "Internet cache folder:  " + tmpStr
  491. tmpStr = FolderLocation(CSIDL_INTERNET, FrmMain.hwnd)
  492. FrmMain.lbl12A.Caption = "Internet folder:  " + tmpStr
  493. tmpStr = FolderLocation(CSIDL_HISTORY, FrmMain.hwnd)
  494. FrmMain.lbl12B.Caption = "History folder:  " + tmpStr
  495. tmpStr = FolderLocation(CSIDL_FONTS, FrmMain.hwnd)
  496. FrmMain.lbl12C.Caption = "Fonts folder:  " + tmpStr
  497. tmpStr = FolderLocation(CSIDL_FAVORITES, FrmMain.hwnd)
  498. FrmMain.lbl12D.Caption = "Favorites folder:  " + tmpStr
  499. tmpStr = FolderLocation(CSIDL_DESKTOP, FrmMain.hwnd)
  500. FrmMain.lbl12E.Caption = "Desktop folder:  " + tmpStr
  501. tmpStr = FolderLocation(CSIDL_COOKIES, FrmMain.hwnd)
  502. FrmMain.lbl12F.Caption = "Cookies folder:  " + tmpStr
  503. tmpStr = FolderLocation(CSIDL_COMMON_DESKTOPDIRECTORY, FrmMain.hwnd)
  504. FrmMain.lbl114.Caption = "Common Desktop folder:  " + tmpStr
  505. End Sub
  506.